<html>
<head><meta charset="utf-8"><title>intra-doc link to field · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html">intra-doc link to field</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220647604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220647604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220647604">(Dec 22 2020 at 00:40)</a>:</h4>
<p>How do I use intra-doc links to link to a field with the same name as a method? E.g.:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">bar</span>: <span class="kt">i32</span> <span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Get a reference to [`Foo::bar`].</span>
<span class="w">    </span><span class="c1">//                            ^^^ I want this to link to the field. Currently it links to the method.</span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">bar</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>I tried using <code>field@</code>, but that doesn't seem to exist.</p>



<a name="220650881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220650881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220650881">(Dec 22 2020 at 01:39)</a>:</h4>
<p>I don't think there's a way to disambiguate that currently</p>



<a name="220652694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220652694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220652694">(Dec 22 2020 at 02:20)</a>:</h4>
<p>Ah, really?</p>



<a name="220652893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220652893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220652893">(Dec 22 2020 at 02:25)</a>:</h4>
<p>Opened an issue: <a href="https://github.com/rust-lang/rust/issues/80283">#80283</a>.</p>



<a name="220676877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220676877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220676877">(Dec 22 2020 at 10:34)</a>:</h4>
<p>You can't use <code>Foo::bar()</code>?</p>



<a name="220689974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220689974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220689974">(Dec 22 2020 at 13:44)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> that will link to the method, not the field</p>



<a name="220690242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690242">(Dec 22 2020 at 13:46)</a>:</h4>
<p>Ah right, if you want the field I don't know how to enforce it...</p>



<a name="220690248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690248">(Dec 22 2020 at 13:46)</a>:</h4>
<p>Maybe <code>Foo.bar</code>?</p>



<a name="220690370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690370">(Dec 22 2020 at 13:48)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> I closed that issue, remember? <a href="https://github.com/rust-lang/rust/issues/75437">https://github.com/rust-lang/rust/issues/75437</a></p>



<a name="220690402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690402">(Dec 22 2020 at 13:48)</a>:</h4>
<p>Now I do</p>



<a name="220690409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690409">(Dec 22 2020 at 13:48)</a>:</h4>
<p>Funny haha</p>



<a name="220690421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690421">(Dec 22 2020 at 13:48)</a>:</h4>
<p>well, any item should have a way to be enforced somehow</p>



<a name="220690467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690467">(Dec 22 2020 at 13:49)</a>:</h4>
<p>instead of "punctuation", we could maybe add specification like in rustdoc search, for example <code>field:Foo::bar</code></p>



<a name="220690475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690475">(Dec 22 2020 at 13:49)</a>:</h4>
<p>but same, need an rfc I guess</p>



<a name="220690625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690625">(Dec 22 2020 at 13:50)</a>:</h4>
<p>I would rather make this consistent with the other disambiguators if we do it at all</p>



<a name="220690645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690645">(Dec 22 2020 at 13:51)</a>:</h4>
<p>I don't think the syntax needs to be special</p>



<a name="220690668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220690668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220690668">(Dec 22 2020 at 13:51)</a>:</h4>
<blockquote>
<p>but same, need an rfc I guess</p>
</blockquote>
<p>I think an FCP would be fine since it's a small change</p>



<a name="220748250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220748250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220748250">(Dec 22 2020 at 23:54)</a>:</h4>
<p>Maybe we could have special-casing for <code>[`field@Foo::bar`]</code> so it renders as <code>Foo.bar</code>?</p>



<a name="220748277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/220748277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#220748277">(Dec 22 2020 at 23:54)</a>:</h4>
<p>That would save a lot of doing <code>[`Foo.bar`][field@Foo::bar]</code>.</p>



<a name="232054216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/intra-doc%20link%20to%20field/near/232054216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/intra-doc.20link.20to.20field.html#232054216">(Mar 27 2021 at 01:55)</a>:</h4>
<p>I started working on this, and I just discovered that we treat fields as if they are in the value namespace. Why is that?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>